<template>
    <Form
            :form-items="formItems"
            :loading="formLoading"
            :init-data-url="$baseURL.auth +  '/auth/oauthclientdetails/' + $route.params.id"
    ></Form>
</template>

<script>
    import Form from '../../../../common-util/src/components/page/Form.vue'
    export default {
        components:{
            Form
        },
        data(){
            return {
                formLoading: false,
                formItems:[
                    {
                        field: {
                            name: 'clientId'
                        },
                        element:{
                            label: '客户端id',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'resourceIds'
                        },
                        element:{
                            label: '资源权限',
                            placeholder: '多个逗号分隔'
                        }
                    },
                    {
                        field: {
                            name: 'clientSecret'
                        },
                        element:{
                            label: '客户端密码',
                            placeholder: '不修改密码请留空'
                        }
                    },
                    {
                        field: {
                            name: 'scope'
                        },
                        element:{
                            label: '授权范围',
                            required: true,
                            placeholder: '多个逗号分隔,如：write,read,all等自定义，目前没有实现'
                        }
                    },
                    {
                        field: {
                            name: 'authorizedGrantTypes'
                        },
                        element:{
                            label: '授权类型',
                            required: true,
                            tips: '多个逗号分隔,只能是：client_credentials,authorization_code,password,refresh_token,wx_mp_code'
                        }
                    },
                    {
                        field: {
                            name: 'webServerRedirectUri'
                        },
                        element:{
                            label: '重定向url',
                            required: (form) => {
                                return form.authorizedGrantTypes ? form.authorizedGrantTypes.indexOf('authorization_code') >= 0 : false
                            },
                            placeholder: 'authorization_code模式时必填,如：http://example.com'
                        }
                    },
                    {
                        field: {
                            name: 'authorities'
                        },
                        element:{
                            label: '权限信息',
                            placeholder: '多个逗号分隔,一般用在client_credentials模式'
                        }
                    },
                    {
                        field: {
                            name: 'accessTokenValidity'
                        },
                        element:{
                            label: 'token时长(s)',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'refreshTokenValidity'
                        },
                        element:{
                            label: '刷新token时长(s)',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'autoapprove'
                        },
                        element:{
                            type: 'switch',
                            label: '自动授权',
                            placeholder: '用在authorization_code模式'

                        }
                    },
                    {
                        field: {
                            name: 'version'
                        }
                    },
                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'put',
                                    url: this.$baseURL.auth +  '/auth/oauthclientdetails/' +this.$route.params.id,
                                    label: '保存'
                                },
                                {
                                    action: 'reset',
                                    label: '重置',
                                    type: 'default'
                                }
                            ]
                        }
                    }
                ]
            }
        },
        mounted(){
        },
        methods:{
        }
    }
</script>

<style scoped>

</style>